var e = require;
var t = module;
var n = exports;
var isLoad = false;
var isTime = false;
Object.defineProperty(n, "__esModule", {
    value: !0
});
var o = e("Privacy"),
    i = cc._decorator,
    a = i.ccclass,
    r = i.property,
    s = function (e) {
        __extends(t, e);
        function t() {
            var t = null !== e && e.apply(this, arguments) || this;
            t.progress = void 0;
            t.progressLabel = void 0;
            t.initComplete = !1;
            t.loadComplete = !1;
            t.progressNum = 0;
            t.progressRun = 0;
            t.hintLabel = null;
            t.privacyPause = !1;
            return t
        }
        t.prototype.onLoad = function () {
            cc.sys.platform == cc.sys.OPPO_GAME || cc.sys.platform == cc.sys.VIVO_GAME || cc.sys.platform == cc.sys.XIAOMI_GAME || cc.sys.platform == cc.sys.BYTEDANCE_GAME || cc.sys.platform == cc.sys.WECHAT_GAME ? this.init() : (isLoad = true) && this.initFinish();
        };
        t.prototype.start = function () {
            SDK.Mgr.Inst.event(SDK.Define.Event.loadingStart);
            SDK.Base.Event.on("PrivacyPause", this.PrivacyPause, this);
            SDK.Base.Event.on("PrivacyResume", this.PrivacyResume, this);
            this.scheduleOnce(() => {
                this.jkzg.active = false;
                isTime = true;
                this.initFinish();
            }, 2);
        };
        t.prototype.onDestroy = function () {
            SDK.Base.Event.off("PrivacyPause", this.PrivacyPause, this);
            SDK.Base.Event.off("PrivacyResume", this.PrivacyResume, this)
        };
        t.prototype.PrivacyPause = function () {
            console.log("PrivacyPause");
            this.privacyPause = !0
        };
        t.prototype.PrivacyResume = function () {
            console.log("PrivacyResume");
            this.privacyPause = !1
        };
        t.prototype.init = function () {
            var e = this,
                t = [],
                n = [],
                o = 0,
                i = 0,
                a = function () {
                    o == t.length && i == n.length && (isLoad = true) && e.initFinish()
                };
            // cc.sys.platform === cc.sys.OPPO_GAME ? t = ["bundle", "frame", "main"] : cc.sys.platform === cc.sys.VIVO_GAME ? t = ["bundle", "frame", "main"] : cc.sys.platform === cc.sys.BYTEDANCE_GAME ? n = ["bundle"] : cc.sys.platform === cc.sys.WECHAT_GAME ? t = ["bundle", "frame", "main"] : cc.sys.platform === cc.sys.XIAOMI_GAME && (t = ["bundle", "frame", "main"]);
            t = ["main2"];
            t.forEach(function (e) {
                cc.loader.downloader.loadSubpackage(e,
                    function (t) {
                        if (t) console.log("%%%%%%% loadSubpackage " + e + " load err", t);
                        else {
                            console.log("%%%%%%% loadSubpackage " + e + " load successfully");
                            o++;
                            a()
                        }
                    })
            });
            // n.forEach(function (e) {
            //     cc.assetManager.loadBundle(e,
            //         function (t) {
            //             if (t) console.log("####### loadBundle " + e + " load err", t);
            //             else {
            //                 console.log("####### loadBundle " + e + " load successfully");
            //                 i++;
            //                 a()
            //             }
            //         })
            // })
        };
        t.prototype.initFinish = function () {
            if (!isLoad || !isTime) return;
            this.initComplete = !0;
            this.loadScene("GameScene");
            this.progress.node.active = !0;
            // if (SDK.Mgr.Inst.curChannel == SDK.Define.Channel.oppo || SDK.Mgr.Inst.curChannel == SDK.Define.Channel.vivo || SDK.Mgr.Inst.curChannel == SDK.Define.Channel.xm)
            // if (cc.sys.localStorage.getItem("PrivacyConfirm")) console.log("PrivacyConfirm", !0);
            // else {
            //     var e = this;
            //     cc.resources.load("SDK/Privacy",
            //         function (t, n) {
            //             if (null == t) {
            //                 var i = n,
            //                     a = cc.instantiate(i);
            //                 cc.director.getScene().getChildByName("Canvas").addChild(a);
            //                 e.scheduleOnce(function () {
            //                     o.default.Instance.openPanel()
            //                 },
            //                     .1)
            //             } else console.log("err", t)
            //         })
            // }
        };
        t.prototype.update = function () {
            if (this.initComplete && !this.privacyPause) {
                if (this.progressRun < this.progressNum) {
                    this.progressRun += .01;
                    this.progress.progress = this.progressRun;
                    this.progressLabel.string = parseInt(100 * this.progressRun + "") + "%"
                }
                this.progressRun >= 1 && cc.director.loadScene("GameScene")
            }
        };
        t.prototype.loadScene = function (e) {
            var t = this;
            cc.director.preloadScene(e,
                function (e, n) {
                    e / n > t.progressNum && (t.progressNum = e / n)
                },
                function () {
                    t.loadComplete = !0
                })
        };
        __decorate([r(cc.ProgressBar)], t.prototype, "progress", void 0);
        __decorate([r(cc.Label)], t.prototype, "progressLabel", void 0);
        __decorate([r(cc.Label)], t.prototype, "hintLabel", void 0);
        __decorate([r(cc.Node)], t.prototype, "jkzg", void 0);
        return __decorate([a], t)
    }(cc.Component);
n.default = s